package com.controller;

import com.pojo.Books;
import com.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/library")
public class BookController
{
    @Autowired
    @Qualifier("BookServiceImpl")
    private BookService bookService;

    @RequestMapping("all")
    public String list(Model model)
    {
        System.out.println("/library/all");
        List<Books> list = bookService.queryAll();
        for (Books item:list
             ) {
            System.out.println(item.getBookName());
        }
        model.addAttribute("list", list);
        return "allBook";
    }
}
